function cre() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else {
        return new ActiveXObject('Microsoft.XMLHTTP');
    }
}
var xhr;
function lo() {
    var form = document.getElementById('logForm');
    var usename = document.getElementById('usename').value;
    var password = document.getElementById('pwdword').value;
    if (usename !== '' && password !== '') {
        xhr = cre();
        xhr.onreadystatechange = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    var lo =JSON.parse(xhr.responseText);
                    console.log(lo);
                    console.log(lo.data.username,typeof lo.code);
                 if(lo.code === 2){
                     localStorage.setItem('user',xhr.responseText);
                    window.location = "http://127.0.0.1:5500/html/head.html";
                 }
                }
            }
        }
        xhr.open('post', 'http://192.168.10.102:8888/login');
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send("username=" + usename + "&password=" + password);
    }
    

}